home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************************/
- /* */
- /* ARDriver.c - A/ROSE driver PB calls. */
- /* */
- /* Richard W. Mincher. February 20, 1990. */
- /* */
- /* Copyright © 1990, Apple Computer, Inc. All rights reserved. */
- /* */
- /********************************************************************************/
-
-
- #include "Types.h"
- #include "Files.h"
- #include "Memory.h"
- #include "Resources.h"
-
- #include "AROSE.h"
- #include "os.h"
-
- #include "ARDriver.h"
- #include "ARTask.h"
-
- void RxComplete(message *m);
-
- pascal OSErr
- ARPBControl(ParmBlkPtr pb, short async)
- {
- AROSEmessage *m;
- struct globals *g;
-
- #ifdef DEBUG
- Debugger();
- #endif DEBUG
- g = (struct globals *)(((pb->cntrlParam.ioCRefNum & 0xF000) << 8) +
- (pb->cntrlParam.ioCRefNum & 0x0180) + 0x200);
- SetMyTid( g->hisTid );
- m = GetMsg();
- m->mTo = (tid_type)(g->myTid);
- m->mCode = SNBControl;
- m->mSData[0] = (unsigned long)pb;
- m->mDataPtr = StripAddress((Ptr)(&(pb->cntrlParam.csCode)));
- m->mDataSize = 24;
- pb->cntrlParam.ioResult = 1;
- Send( m );
- if (!async)
- {
- while(pb->cntrlParam.ioResult > 0)
- PushAIPC();
- return (pb->cntrlParam.ioResult);
- }
- else
- return (noErr);
- }
-
- pascal OSErr
- ARPBKillIO(ParmBlkPtr pb, short async)
- {
- pb->cntrlParam.csCode = 1;
- return (ARPBControl(pb, async));
- }
-
- //pascal OSErr
- //ARPBStatus(ParmBlkPtr pb, short async)
- //{
- // AROSEmessage *m;
- // long *addr;
- //
- //#ifdef DEBUG
- // Debugger();
- //#endif DEBUG
- // addr = (long *)(((pb->cntrlParam.ioCRefNum & 0xFF00) << 8) +
- // (pb->cntrlParam.ioCRefNum & 0xFF) + 0x700);
- // SetMyTid(addr[1]);
- // m = GetMsg();
- // m->mTo = (tid_type)(addr[0]);
- // m->mFrom = (tid_type)(addr[1]);
- // m->mCode = SNBStatus;
- // m->mSData[0] = (unsigned long)pb;
- // m->mDataPtr = StripAddress((Ptr)(&(pb->cntrlParam.csCode)));
- // m->mDataSize = 24;
- // pb->cntrlParam.ioResult = 1;
- // Send( m );
- // if (!async)
- // {
- // while(pb->cntrlParam.ioResult > 0)
- // PushAIPC();
- // return (pb->cntrlParam.ioResult);
- // }
- // else
- // return (noErr);
- //}
-
- pascal OSErr
- ARPBStatus(ParmBlkPtr pb, short async)
- {
- struct globals *g;
- ProcPtr cmp;
-
- #ifdef DEBUG
- Debugger();
- #endif DEBUG
- g = (struct globals *)(((pb->cntrlParam.ioCRefNum & 0xF000) << 8) +
- (pb->cntrlParam.ioCRefNum & 0x0180) + 0x200);
- pb->cntrlParam.ioResult = 0;
- switch(pb->cntrlParam.csCode)
- {
- case 2:
- pb->cntrlParam.csParam[0] = 0;
- BlockMove( (Ptr)(&(g->sRxCount)), (Ptr)(&(pb->cntrlParam.csParam[1])), 2 );
- break;
- case 8:
- BlockMove( (Ptr)(&(g->asyncErr)), (Ptr)(pb->cntrlParam.csParam), 6 );
- break;
- default:
- pb->cntrlParam.ioResult = -17;
- break;
- }
- if (async)
- {
- cmp = (ProcPtr)StripAddress((Ptr)(pb->ioParam.ioCompletion));
- if (cmp)
- ARComplete( pb, cmp, pb->ioParam.ioResult );
- }
- return (pb->cntrlParam.ioResult);
- }
-
- pascal OSErr
- ARPBWrite(ParmBlkPtr pb, short async)
- {
- AROSEmessage *m;
- struct globals *g;
-
- #ifdef DEBUG
- Debugger();
- #endif DEBUG
- g = (struct globals *)(((pb->cntrlParam.ioCRefNum & 0xF000) << 8) +
- (pb->cntrlParam.ioCRefNum & 0x0180) + 0x200);
- SetMyTid(g->hisTid);
- m = GetMsg();
- m->mTo = (tid_type)(g->myTid);
- m->mCode = SNBWrite;
- m->mSData[0] = (unsigned long)pb;
- m->mSData[1] = (unsigned long)(pb->ioParam.ioRefNum);
- m->mDataPtr = StripAddress(pb->ioParam.ioBuffer);
- m->mDataSize = pb->ioParam.ioReqCount;
- pb->ioParam.ioResult = 1;
- Send( m );
- if (!async)
- {
- while(pb->ioParam.ioResult > 0)
- PushAIPC();
- return (pb->ioParam.ioResult);
- }
- else
- return (noErr);
- }
-
- pascal OSErr
- ARPBRead(ParmBlkPtr pb, short async)
- {
- AROSEmessage *m;
- struct globals *g;
-
- #ifdef DEBUG
- Debugger();
- #endif DEBUG
- g = (struct globals *)(((pb->cntrlParam.ioCRefNum & 0xF000) << 8) +
- (pb->cntrlParam.ioCRefNum & 0x0180) + 0x200);
- SetMyTid( g->hisTid );
- m = GetMsg();
- m->mTo = (tid_type)(g->myTid);
- m->mFrom = (tid_type)(g->hisTid);
- m->mCode = SNBRead;
- m->mSData[0] = (unsigned long)pb;
- m->mSData[1] = (unsigned long)(pb->ioParam.ioRefNum);
- m->mDataPtr = StripAddress(pb->ioParam.ioBuffer);
- m->mDataSize = pb->ioParam.ioReqCount;
- pb->ioParam.ioResult = 1;
- Send( m );
- if (!async)
- {
- while(pb->ioParam.ioResult > 0)
- PushAIPC();
- return (pb->ioParam.ioResult);
- }
- else
- return (noErr);
- }
-
- void
- RxComplete(AROSEmessage *m)
- {
- ProcPtr cmp;
- ParmBlkPtr pb;
-
- #ifdef DEBUG
- Debugger();
- #endif DEBUG
- pb = (ParmBlkPtr)StripAddress((Ptr)(m->mSData[0]));
- cmp = (ProcPtr)StripAddress((Ptr)(pb->ioParam.ioCompletion));
- if ((m->mCode == SNBWrite+1) || (m->mCode == SNBRead+1))
- pb->ioParam.ioActCount = m->mDataSize;
- pb->ioParam.ioResult = m->mStatus;
- FreeMsg( m );
- (void)Receive( 0, 0, 0, 0, RxComplete );
- if (cmp)
- ARComplete( pb, cmp, pb->ioParam.ioResult );
- }